package com.hdax.dm.api.user.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hdax.dm.api.user.LinkUserControllerApi;
import com.hdax.dm.entity.user.LinkUser;
import com.hdax.dm.service.LinkUserPService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class LinkUserPController implements LinkUserControllerApi {

    @Autowired
    private LinkUserPService linkUserService;

    @Override
    public List<LinkUser> findByUserId(Long userId) {
        QueryWrapper<LinkUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("userId",userId);
        List<LinkUser> list = linkUserService.list(queryWrapper);
        return list;
    }

    @Override
    public LinkUser getById(Long id) {
        QueryWrapper<LinkUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",id);
        LinkUser one = linkUserService.getOne(queryWrapper);
        return one;
    }

    @Override
    public boolean validatebuyerexist(String idCard) {
        QueryWrapper<LinkUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("idCard",idCard);
        LinkUser one = linkUserService.getOne(queryWrapper);
        return one==null?true:false;
    }

    @Override
    public boolean addticketbuyer(LinkUser linkUser) {
        return linkUserService.addticketbuyer(linkUser);
    }
}
